home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3940 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  53 lines

  1. Newsgroups: comp.lang.c
  2. Path: newsstand.cit.cornell.edu!ub!csn!alisa!wjjr
  3. From: wjjr@alisa.org (John J. Rushford Jr.)
  4. Subject: Re: E-mail from within a Program
  5. Sender: news@alisa.org
  6. Message-ID: <DM2so5.JtG@alisa.org>
  7. Date: Thu, 1 Feb 1996 02:38:29 GMT
  8. References: <4eoepe$kov@serveru1.naic.wpafb.af.mil>
  9. Nntp-Posting-Host: alisa
  10. Organization: My place on the Front Range
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Keith D. Anthony - NAIC/TATA - 513-257-6351 (kda36@naic.wpafb.af.mil) wrote:
  14.  
  15. : I'm attempting to write code that generates a file, probably
  16. : in /tmp, e-mails this file to a userid, and does all this for 
  17. : a list of users.
  18.  
  19. : Have tried as a first attempt:
  20.  
  21. : char *arg1[7];
  22.  
  23. : arg1[0] = "mail";
  24. : arg1[1] = "-s";
  25. : arg1[2] = "test message";
  26. : arg1[3] = "userid";
  27. : arg1[4] = " < "        /* have even tried \<*/
  28. : arg1[5] = "/tmp/filename";
  29. : arg1[6] = NULL;
  30.  
  31. : (sending to myself) I get a blank message and another one
  32. : apparently going to "< userid".  
  33.  
  34. : Do I need to manipulated some file descriptors?  
  35. : Anyone done something like this?  Can anyone offer some code
  36. : to e-mail files under program control (yes, in C).
  37.  
  38. : Oh yes, this is the generic C compiler under SUNOS 4.1.3.
  39.  
  40. : Thanks, and please e-mail any suggestions.  I happily summarize
  41. : and repost.
  42.  
  43. The '<' is a meta character recognized by the 'bourne shell'.  You'd need to
  44. modify your execl() to do something like:
  45.  
  46.    execl ("/bin/sh", "sh", "-c", "mailx", "-s", "test message", "userid",
  47.           "<", "/tmp/filename", (char *)NULL);
  48.  
  49. This should work.
  50.  
  51. John Rushford
  52. wjjr@alisa.org
  53.